//
//  MineDuobaoController.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/15.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit

class MineDuobaoController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
    
    let CellId:String = "CELLID"
    
    var tableView:UITableView = UITableView.init()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.createUI()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.setNavi()
    }
}
extension MineDuobaoController{
    //MARK:设置导航栏选项
    func setNavi(){
        self.navigationItem.title = "夺宝记录"
        self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.black]
        self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "", imagStr: "ic_back", fontSize: 14, target: self, action: #selector(leftBarButtonAction))
    }
    //MARK:LeftBarButtonAction
    func leftBarButtonAction(){
        self.navigationController!.popViewController(animated: true)
    }
    func createUI(){
       self.view.addSubview(self.tableView)
        self.tableView.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.top.equalTo(0)
            make.bottom.equalTo(0)
        }
        self.tableView.delegate = self
        self.tableView.dataSource = self
        self.tableView.register(MineDingDanCell.self, forCellReuseIdentifier: CellId)
    }
    @objc(numberOfSectionsInTableView:) func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 2
    }
    @objc(tableView:didSelectRowAtIndexPath:) func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print("selected")
    }
    @objc(tableView:heightForRowAtIndexPath:) func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.row == 0{
            return 75 + 24 + 28
        }else{
            return 24+28+16+96
        }
    }
    @objc(tableView:cellForRowAtIndexPath:) func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell:MineDingDanCell = tableView.dequeueReusableCell(withIdentifier: CellId) as! MineDingDanCell
        if indexPath.row == 0{
            cell.dingdanTYpe = .goingType
            cell.nameLabel.text = "沙县小吃"
            cell.qhLabel.text = "期号:312145"
            cell.joinLabel.text = "本期参与:6人次"
        }else {
            cell.dingdanTYpe = .noRushType
            cell.nameLabel.text = "芝士蛋糕"
            cell.qhLabel.text = "期号:312145"
            cell.joinLabel.text = "本期参与:22人次"
            cell.winerLabel.text = "得宝者:jason"
            cell.dateLabel.text = "2016-05-31"
        }
        cell.dataDic = ["":""]
        return cell
    }
}

